package com.hl.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hl.sfzy.entity.ArticleType;
import com.hl.sfzy.mapper.ArticleTypeMapper;
import com.hl.sfzy.service.ArticleTypeServcie;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ArticleTypeServcieIpml implements ArticleTypeServcie {
    @Autowired
    private ArticleTypeMapper articleTypeMapper;
    @Override
    public int add(ArticleType articleType) {
        return articleTypeMapper.insert(articleType);
    }

    @Override
    public int remove(Long id) {
       return articleTypeMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int edit(ArticleType articleType) {
        return articleTypeMapper.updateByPrimaryKey(articleType);
    }

    @Override
    public ArticleType findById(Long id) {
        return articleTypeMapper.selectByPrimaryKey(id);
    }

    @Override
    public PageInfo<ArticleType> findAll(int pageNum, int pageSize, ArticleType articleType) {
        PageHelper.startPage(pageNum,pageSize);
        List<ArticleType> list = articleTypeMapper.selectAll(articleType);
        return new PageInfo<>(list);
    }
    @Override
    public int deleteBatch(List<Long> ids) {
        return articleTypeMapper.deleteBatch(ids);
    }
}
